namespace TestForFulentApi.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class _4446533dwded : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Articles", "AuthorId", "dbo.Authors");
            CreateTable(
                "dbo.Blogs_Authors",
                c => new
                    {
                        Blog_Id = c.Int(nullable: false),
                        Author_Id = c.Int(nullable: false),
                    })
                .PrimaryKey(t => new { t.Blog_Id, t.Author_Id })
                .ForeignKey("dbo.Blogs", t => t.Blog_Id, cascadeDelete: true)
                .ForeignKey("dbo.Authors", t => t.Author_Id, cascadeDelete: true)
                .Index(t => t.Blog_Id)
                .Index(t => t.Author_Id);
            
            AddForeignKey("dbo.Articles", "AuthorId", "dbo.Authors", "Id");
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Articles", "AuthorId", "dbo.Authors");
            DropForeignKey("dbo.Blogs_Authors", "Author_Id", "dbo.Authors");
            DropForeignKey("dbo.Blogs_Authors", "Blog_Id", "dbo.Blogs");
            DropIndex("dbo.Blogs_Authors", new[] { "Author_Id" });
            DropIndex("dbo.Blogs_Authors", new[] { "Blog_Id" });
            DropTable("dbo.Blogs_Authors");
            AddForeignKey("dbo.Articles", "AuthorId", "dbo.Authors", "Id", cascadeDelete: true);
        }
    }
}
